package view.GUI.adminView.coreData.people.customer;

import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import model.data.tableModel.person.Person;

import org.controlsfx.validation.ValidationSupport;

import view.GUI.adminView.coreData.people.AbstractPeopleView;
import view.GUI.mainView.MainView;
import view.Validator.NameValidator;
import enums.GUIText;

public abstract class CustomerView extends AbstractPeopleView {

	private Label lblName;
	private Label lblPerson;

	protected TextField txtCustomerName;

	protected ComboBox<Person> cmbPerson;

	public CustomerView(boolean isEdit, GUIText title, MainView instance) {
		super(isEdit, 3, instance, title);
		txtCustomerName = new TextField();
		lblName = new Label(GUIText.CUSTOMERNAME.toString());
		lblPerson = new Label(GUIText.PERSON.toString());
		cmbPerson = new ComboBox<>();
		cmbPerson.getItems().addAll(owner.getPersons());
		
		
		addNode(lblName, 0, 1);
		addNode(txtCustomerName, 1 , 1);
		addNode(lblPerson, 0,2);
		addNode(cmbPerson, 1,2);

		valSup.registerValidator(txtCustomerName, true, new NameValidator());
		ValidationSupport.setRequired(cmbPerson, true);
	}
}
